package com.fz.song.enums;

import java.io.File;

/**
 * Created by sfz on 2017/10/17.
 */
public enum ExceptionEnum {

    TEST(9999, "测试数据"),
    SYSTEM_ERROR(-1, "系统错误"),
    FAIL(0, "失败"),
    SUCCESS(1, "成功"),
    //一般异常
    PARAM_EXCEPTION(1001, "参数异常"),
    NULL_EXCEPTION(1002, "空指针异常"),
    NOTONLY_EXCEPTION(1003, "不是唯一的"),
    DATA_NO_FOUND(1004, "数据找不到"),
    //登陆异常集合
    LOGIN_EXCEPTION(1100, "登录异常"),
    USER_NOT_EXISTS(1101, "用户不存在"),
    PWD_ERROR(1102, "密码错误"),
    USER_NOT_ONLY(1103, "用户不唯一"),
    USERNAME_IS_NULL(1104, "用户名为空"),
    PWD_IS_NULL(1105, "密码为空"),
    VALIDATE_CODE_IS_NULL(1106, "验证码为空"),
    VALIDATE_ERROR(1107, "验证码错误"),
    ILLEGAL_LOGON(1008, "非法登录"),
    PASSWORD_EXPIRE(1109, "密码过期,请重新登录"),
    VALIDATE_EXPIRE(1110, "验证码过期,请刷新验证码");


    private int code;
    private String Message;

    ExceptionEnum(int code, String message) {
        this.code = code;
        Message = message;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return Message;
    }

    public void setMessage(String message) {
        Message = message;
    }

    public ExceptionEnum getByValue(int code) {
        for (ExceptionEnum exceptionEnum : ExceptionEnum.values()) {
            if (exceptionEnum.code == code) {
                return exceptionEnum;
            }
        }
        throw new IllegalArgumentException("找不到该code: " + code);
    }


}
